package com.gitee.qdbp.jdbc.plugins.impl;

import com.gitee.qdbp.jdbc.exception.UnsupportedFieldException;
import com.gitee.qdbp.jdbc.plugins.ColumnNameResolver;
import com.gitee.qdbp.jdbc.plugins.DbPluginHelper;
import com.gitee.qdbp.jdbc.plugins.JdbcNamingConverter;

/**
 * 调用JdbcNamingConverter的ColumnNameResolver
 *
 * @author zhaohuihua
 * @version 20210510
 */
public class ColumnNamingConverter implements ColumnNameResolver {

    /** 插件容器 **/
    protected final DbPluginHelper plugins;
    
    public ColumnNamingConverter(DbPluginHelper plugins) {
        this.plugins = plugins;
    }

    @Override
    public String getColumnName(String fieldName) throws UnsupportedFieldException {
        if (fieldName == null) {
            return null;
        }
        JdbcNamingConverter converter = plugins.getNamingConverter();
        return converter.fieldNameToColumnName(fieldName);
    }
}
